home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 24
/
Aminet 24 (1998)(GTI - Schatztruhe)[!][Apr 1998].iso
/
Aminet
/
text
/
edit
/
GED_Hexedit.lha
/
GED_Hexedit
/
hex
/
english
/
searchbytes.ged
< prev
Wrap
Text File
|
1998-01-02
|
5KB
|
2 lines
/* Optimized with RexxOpt 1.8 */
OPTIONS RESULTS;if (LEFT(ADDRESS(),6) ~="GOLDED") then;address 'GOLDED.1';'LOCK CURRENT RELEASE=4';if (RC ~=0) then;exit;OPTIONS FAILAT 6;SIGNAL ON SYNTAX;'QUERY Var=Wild Name=Wildcards';'QUERY Var=Suchbytes Name=Find';'Query Var=Ersetzenstring Name=Rplc';parse arg start;if start="1"|start="e" then;do;if length(Suchbytes)>32 then Suchbytes=left(Suchbytes,32);'REQUEST Body="Enter bytes in hex-format (max 16 bytes):" Title="Input" Button="!OK|Cancel" Var=Suchbytes Min=2 Max=32 String Old=' Suchbytes;if RC>0 then;do;'UNLOCK';exit;end;end;if length(Suchbytes)=0|length(Suchbytes)//2 ~=0 then;do;'REQUEST Problem="You have to enter hex digits in pairs"';'UNLOCK';exit;end;Suchbytes=Upper(Suchbytes);if verify(Suchbytes,'0123456789ABCDEF?')~=0&Wild=TRUE then;do;'REQUEST Problem="You may only enter hex digits (0...9 or a...f) or ?"';'UNLOCK';exit;end;if verify(Suchbytes,'0123456789ABCDEF')~=0&Wild=FALSE then;do;'REQUEST Problem="You may only enter hex digits (0...9 or a...f)"';'UNLOCK';exit;end;if Wild=TRUE&pos("?",Suchbytes)>0&pos("?",Suchbytes)<3 then;do;'REQUEST Problem="The first two chars of the search string may not be a wildcard"';'UNLOCK';exit;end;'QUERY Var=Startzeile Name=Line';'QUERY Var=Startspalte Name=Column';Z1=Startzeile;S1=Startspalte;Byteanz=length(Suchbytes)/2;Actbyte=left(Suchbytes,2);'QUERY Var=Anzzeilen Name=Lines';do forever;'FIND Next Quiet String='Actbyte;'QUERY Var=Z2 Name=Line';'QUERY Var=S2 Name=Column';if Z1=Z2&S1=S2 then;do;'GOTO Line='Startzeile;'GOTO Column='Startspalte;'REQUEST Body="Search string not found" Title="Result" Button="!OK"';'SET Name=Find Value='Suchbytes;'UNLOCK';exit;end;if S2=11|S2=13|S2=15|S2=17|S2=20|S2=22|S2=24|S2=26|S2=29|S2=31|S2=33|S2=35|S2=38|S2=40|S2=42|S2=44 then;do;if Byteanz=1 then;do;'SET Name=Find Value='Suchbytes;if start="e" then call ersetzen;'UNLOCK';exit;end;'QUERY Var=Inhalt Name=Buffer';t1=substr(Inhalt,S2,46-S2);t1=compress(t1);if length(t1)/2<Byteanz then;do;if Z2<Anzzeilen then;do;'DOWN';'QUERY Var=Inhalt Name=Buffer';'UP';'GOTO Column='S2;t=Byteanz-length(t1)/2;t2=compress(substr(Inhalt,11,2*t));t1=t1||t2;if Wild=TRUE&index(Suchbytes,"?")>0 then;do;t1=suchewild(t1,Suchbytes);end;if t1=Suchbytes then;do;'SET Name=Find Value='Suchbytes;if start="e" then call ersetzen;'UNLOCK';exit;end;end;end;else;do;if Wild=TRUE&index(Suchbytes,"?")>0 then;do;t1=suchewild(t1,Suchbytes);end;if Suchbytes=left(t1,length(Suchbytes)) then;do;'SET Name=Find Value='Suchbytes;if start="e" then call ersetzen;'UNLOCK';exit;end;end;end;Z1=Z2;S1=S2;end;if start="e" then call ersetzen;'UNLOCK';exit;suchewild:procedure;PARSE ARG w,such;do i=1 to length(such);if substr(such,i,1)=="?" then w=overlay("?",w,i,1);end;return w;ersetzen:;'SET Name=Insert Value=False';flag=1;do while flag;flag=0;'REQUEST Body="Enter replace string in hex format ('||length(Suchbytes)||' chars):" Title="Input" Button="!OK|Cancel" Var=Ersetzenstring Max='||length(Suchbytes)||' String Old=' Ersetzenstring;if RC>0 then;do;'UNLOCK';exit;end;Ersetzenstring=upper(Ersetzenstring);if length(Ersetzenstring) ~=length(Suchbytes) then;do;'REQUEST Problem="The replace string must have same length as the search string"';flag=1;end;if verify(Ersetzenstring,'0123456789ABCDEF')~=0 then;do;'REQUEST Problem="You may only enter hex digits (0...9 or a...f)"';flag=1;end;end;'SET Name=Rplc Value='||Ersetzenstring;'QUERY Name=Column Var=Spalte';'QUERY Name=Buffer Var=Inhalt';Spalte1=(Spalte-10)-(Spalte-10)%9;Zeile1=compress(substr(Inhalt,11,35));Zeile2=substr(Inhalt,48);Ersetzenstring2="";if length(Ersetzenstring)>33-Spalte1 then;do;Ersetzenstring2=right(Ersetzenstring,length(Ersetzenstring)+Spalte1-30);Ersetzenstring=left(Ersetzenstring,length(Ersetzenstring)-length(Ersetzenstring2));end;'GOTO Column=1';Zeile1=overlay(Ersetzenstring,Zeile1,Spalte1);Zeile2=overlay(x2c(Ersetzenstring),Zeile2,(Spalte1+1)%2);Inhalt=overlay(substr(Zeile1,1,8),Inhalt,11);Inhalt=overlay(substr(Zeile1,9,8),Inhalt,20);Inhalt=overlay(substr(Zeile1,17,8),Inhalt,29);Inhalt=overlay(substr(Zeile1,25,8),Inhalt,38);Inhalt=overlay(substr(Zeile2,1,16),Inhalt,48);'FIX Var=Inhalt';'TEXT stay T="'||Inhalt||'"';if length(Ersetzenstring2)>0 then;do;'DOWN';'QUERY Name=Buffer Var=Inhalt';Zeile1=compress(substr(Inhalt,11,35));Zeile2=substr(Inhalt,48);Zeile1=overlay(c2x(Ersetzenstring2),Zeile1,1);Zeile2=overlay(Ersetzenstring2,Zeile2,1);Inhalt=overlay(substr(Zeile1,1,8),Inhalt,11);Inhalt=overlay(substr(Zeile1,9,8),Inhalt,20);Inhalt=overlay(substr(Zeile1,17,8),Inhalt,29);Inhalt=overlay(substr(Zeile1,25,8),Inhalt,38);Inhalt=overlay(substr(Zeile2,1,16),Inhalt,48);'FIX Var=Inhalt';'TEXT stay T="'||Inhalt||'"';'UP';end;'GOTO Column='||Spalte;return;SYNTAX:;SAY "Sorry, error line" SIGL ":" ERRORTEXT(RC) ":-(";'UNLOCK';exit